package com.aggregate.pay.saobei;

import com.aggregate.pay.saobei.bean.BarcodePayData;
import com.aggregate.pay.saobei.bean.BarcodePayResult;
import com.aggregate.pay.saobei.bean.JsPayData;
import com.aggregate.pay.saobei.bean.JsPayResult;
import com.aggregate.pay.saobei.bean.PayNotifyData;
import com.aggregate.pay.saobei.bean.PayNotifyResult;
import com.aggregate.pay.saobei.bean.QueryOrderData;
import com.aggregate.pay.saobei.bean.QueryOrderResult;
import com.aggregate.pay.saobei.bean.RefundData;
import com.aggregate.pay.saobei.bean.RefundResult;
import com.aggregate.pay.saobei.bean.WapPayData;
import com.aggregate.pay.saobei.support.Client;
import com.aggregate.pay.saobei.support.Config;
import com.aggregate.pay.saobei.support.Factory;
import com.aggregate.pay.saobei.support.HttpClient;
import com.aggregate.pay.saobei.support.Merch;

/**
 * 扫呗支付接口工具类，相关配置和接口调用从此类开始
 * @author Moyq5
 * @date 2018年6月27日
 */
public abstract class SaobeiApiFactory {

	public static void config(Config config, HttpClient httpClient) {
		Factory.setConfig(config);
		Factory.setHttpClient(httpClient);
	}
	
	@SuppressWarnings("unchecked")
	public static Client<WapPayData, String> wapPayClient(Merch info) {
		return (Client<WapPayData, String>)Factory.getClient(SaobeiApiType.WAP_PAY, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<PayNotifyData, PayNotifyResult> payNotifyClient(Merch info) {
		return (Client<PayNotifyData, PayNotifyResult>)Factory.getClient(SaobeiApiType.PAY_NOTIFY, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<QueryOrderData, QueryOrderResult> queryOrderClient(Merch info) {
		return (Client<QueryOrderData, QueryOrderResult>)Factory.getClient(SaobeiApiType.QUERY_ORDER, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<RefundData, RefundResult> refundClient(Merch info) {
		return (Client<RefundData, RefundResult>)Factory.getClient(SaobeiApiType.REFUND, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<JsPayData, JsPayResult> jsPayClient(Merch info) {
		return (Client<JsPayData, JsPayResult>)Factory.getClient(SaobeiApiType.JS_PAY, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<String, String> authOpenIdClient(Merch info) {
		return (Client<String, String>)Factory.getClient(SaobeiApiType.AUTH_OPEN_ID, info);
	}

	@SuppressWarnings("unchecked")
	public static Client<BarcodePayData, BarcodePayResult> barcodePayClient(Merch info) {
		return (Client<BarcodePayData, BarcodePayResult>)Factory.getClient(SaobeiApiType.BARCODE_PAY, info);
	}

}
